05. Installing Tensorflow

Throughout this lesson, you'll apply your knowledge of neural networks on real datasets using TensorFlow (link for China), an open source Deep Learning library created by Google.

You’ll use TensorFlow to classify images from the notMNIST dataset - a dataset of images of English letters from A to J. You can see a few example images below.

Your goal is to automatically detect the letter based on the image in the dataset. You’ll be working on your own computer for this lab, so, first things first, install TensorFlow!

Install Tensorflow

The following instructions are meant to be carried out on your computer instead of the VM.
Note: Currently, we will be working with TF version 1.2.1 for the rest of this module and will update to the latest TF version later.

Prerequisites

The RoboND environment requires Python 3.5 64-bit and Anaconda. During the first week of the ND, you went through the installation for Anaconda. You can follow the steps pointed out here in case you want to reinstall the software.

The RoboND environment already includes TF v1.2.1, so if you installed the environment, you are good to go! The following set of instructions can give you an idea of how you can install it on your own as well, if needed.

Once you have Anaconda setup with the required python version, run the following commands via the terminal or command line, to setup your environment:

OS X and Linux (Ubuntu)

source activate RoboND
pip install tensorflow==1.2.1

Windows

source activate RoboND 
# if the above throws an error, you can run "activate RoboND" instead
pip install tensorflow==1.2.1

**Note: ** The above steps will help you install the CPU version for Tensorflow only. Later, we will cover instructions on using AWS which will allow you access to a GPU which will be helpful for future labs and the final project! If you do wish to install the GPU version you can follow the instructions on the TF website.

That's it! You have a working environment with TensorFlow. Test it out with the code in the Hello, world! section below.

Hello, world!

Try running the following code in your Python console to make sure you have TensorFlow properly installed. The console will print "Hello, world!" if TensorFlow is installed. Don’t worry about understanding what it does. You’ll learn about it in the next section.

First, start the Python shell in your Anaconda environment by simply entering:

$ python

And then, in the shell enter the following commands:

import tensorflow as tf

# Create TensorFlow object called tensor
hello_constant = tf.constant('Hello World!')

with tf.Session() as sess:
    # Run the tf.constant operation in the session
    output = sess.run(hello_constant)
    print(output)